import { request } from '../requests'
import { buildPostApi } from './index'
import { buildGetApi } from './index'

export const ssoLogin = (id_token: string) =>
  request(buildPostApi('/auth/login'), { id_token }, {}, true, false) as Promise<any>

export const getToken = () => request(buildGetApi('/token'), {}, {}, false, false) as Promise<any>

export const verifyLogin = (token: string) =>
  request(buildPostApi('/token'), {}, { token }, true, false) as Promise<any>

export const getUserInfo = () => request(buildGetApi('/user/info'), {}, {}, false, false) as Promise<any>

export const bindPhoneNumber = (phoneNumber: string, msgCode: string) => request(buildPostApi('/user/bind/phoneNumber'), { phoneNumber, msgCode }, {}, true, false) as Promise<any>

export const pwdlogin = (loginId: string, password: string, graphCode: string) =>
  request(buildPostApi('/login'), { loginId, password, graphCode }, {}, true, false) as Promise<any>

export const msgLogin = (phoneNumber: string, msgCode: string) =>
  request(buildPostApi('/login/msg'), { phoneNumber, msgCode }, {}, true, false) as Promise<any>
